#include <iostream>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <errno.h>
#include <error.h>
#include <unistd.h>
#include <string>
using namespace std;

int main()
{
    int ret = truncate("test.txt", 200);
    if (ret == -1)
    {
        perror("truncate error:");
        exit(-1);
    }
    struct stat buf;
    stat("test.txt", &buf);
    cout << "size:" << buf.st_size << endl;
    return 0;
}